package com.xiu.weixin.service.wx;

import java.util.Map;

import org.springframework.stereotype.Service;

import com.xiu.weixin.pojo.message.Message;
import com.xiu.weixin.service.wx.event.click.ClickEventService;
import com.xiu.weixin.service.wx.event.view.ViewEventService;
import com.xiu.weixin.service.wx.message.image.ImageMessageService;
import com.xiu.weixin.service.wx.message.text.TextMessageService;
import com.xiu.weixin.service.wx.message.voice.VoiceMessageService;
import com.xiu.weixin.util.XmlUtil;

@Service
public class WxService {

	public String doService(Map<String, String> reqMap) {
		String msgType = reqMap.get("MsgType");
		Message rspMessage = null;
		switch (msgType) {
		case "event":
			String event = reqMap.get("Event");
			switch (event) {
			case "CLICK":
				rspMessage = ClickEventService.doService(reqMap);
				break;
			case "VIEW":
				rspMessage = ViewEventService.doService(reqMap);
				break;
			}
			break;
		case "text":
			rspMessage = TextMessageService.doService(reqMap);
			break;
		case "image":
			rspMessage = ImageMessageService.doService(reqMap);
			break;
		case "voice":
			rspMessage = VoiceMessageService.doService(reqMap);
			break;
		case "video":
			break;
		case "shortvideo":
			break;
		case "location":
			break;
		case "link":
			break;
		}
		if (rspMessage != null) {
			return XmlUtil.beanToXml(rspMessage);
		}
		return "";
	}

}
